$(function() {
		$("#btnLogin").on("click", function() {
			var userName = $(".username").val();
			var pwd = $(".password").val();

			$.post("php/login.php", {
				"username": userName,
				"userpass": pwd
			}, function(data) {
				// console.log(data);
				if (data == "success") {
					let date = new Date();
					date.setDate(date.getDate() + 7);
					document.cookie = `user=${$(".username").val()};expires=` + date;
					console.log(document.cookie);
					alert("登录成功!");
					location = "index.html";
				} else {
					alert("用户名或密码有误！");
					location = "login1.html";
				}
			});
		});
	});
	// let cookie1 = document.cookie;
	// if (cookie1.length > 0) {
	// 	let c = cookie1.split("=");
	// 	// console.log(c);
	// 	document.querySelector(".header-top-l").innerHTML = "你好！" + c[1];
	// }